﻿using AnQinFrameWorkAPI.Entity.SystemCore.DTO.MenuField;
using AnQinFrameWorkAPI.Entity.SystemCore.View.MenuField;
using AnQinFrameWorkAPI.Service.SystemCore;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.SystemCore;

/// <summary>
///     菜单字段API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "SystemCore")]
public class MenuFieldController : ControllerBase
{
    //业务接口
    private readonly MenuFieldService _menuFieldService;

    //构造注入
    public MenuFieldController(MenuFieldService menuFieldService)
    {
        _menuFieldService = menuFieldService;
    }

    /// <summary>
    ///     获取菜单字段列表
    /// </summary>
    [ProducesResponseType(typeof(MenuFieldView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetMenuFieldList([FromQuery] MenuFieldSearchDTO menuFieldSearchDTO)
    {
        var response = await _menuFieldService.GetMenuFieldList(menuFieldSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增菜单字段
    /// </summary>
    /// <params name="menuFieldAddDTO"></params>
    [HttpPost]
    public async Task<IActionResult> AddMenuField([FromBody] MenuFieldAddDTO menuFieldAddDTO)
    {
        var response = await _menuFieldService.AddMenuField(menuFieldAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     编辑菜单字段
    /// </summary>
    /// <params name="menuFieldUpdateDTO"></params>
    [HttpPut]
    public async Task<IActionResult> PutMenuField([FromBody] MenuFieldUpdateDTO menuFieldUpdateDTO)
    {
        var response = await _menuFieldService.PutMenuField(menuFieldUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除菜单字段
    /// </summary>
    [HttpDelete]
    public async Task<IActionResult> DeleteMenuField([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _menuFieldService.DeleteMenuField(deleteDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     批量删除菜单字段
    /// </summary>
    [HttpDelete("DeleteMulti")]
    public async Task<IActionResult> DeleteArrayMenuField([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _menuFieldService.DeleteArrayMenuField(idArrayDTO);
        return StatusCode(response.Status, response);
    }
}